Skip to content

Address a StandardOutput Format bug; 1849: #1852

Merged
mmatera merged 4 commits into
masterfrom
fix_1849
Jul 6, 2026
Merged

Address a StandardOutput Format bug; 1849: #1852
mmatera merged 4 commits into
masterfrom
fix_1849

Conversation

@mmatera

@mmatera mmatera commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The origin of the issue was that when string_render_output_form does not get a string, fall back to the default format function. In the example, `

 mathics -c 'xx="a string"; StringTake[xx[0]]'

produced an expression with a String as the head:

In[1]:= xx="a string"
Out[1]= "a string"

In[2]:= xx[0] //FullForm
Out[2]//FullForm= "a string"[0]

When render_output_form asks for the lookup_name of the callback function, it get SystemString. But that function just processes Stringatoms, not expressions with aString` as its head. This patch just raise the exception that produces to the parent function to use the default render function.

So, now we get

StringTake::argr: StringTake called with 1 argument; 2 arguments are expected.
StringTake[a string[0]]
```

Notice that if instead of a string, the head was an integer, the result was already right:
```
(Mathics3) mauricio@mauricio-T15thinkpad:~/Projects/mathics-core$ mathics -c 'xx=7; StringTake[xx[0]]'
StringTake::argr: StringTake called with 1 argument; 2 arguments are expected.
StringTake[7[0]]
```




Comment thread mathics/format/form/outputform.py Outdated
@rocky rocky changed the title fix 1849: Address a StandardOutput Format bug; 1849: Jul 6, 2026
@rocky

rocky commented Jul 6, 2026

Copy link
Copy Markdown
Member

LGTM

@mmatera mmatera merged commit dd198c3 into master Jul 6, 2026
18 checks passed
@mmatera mmatera deleted the fix_1849 branch July 6, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants